﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CentaLine.Model
{
    /// <summary>
    /// 业务员虚拟电话申请模型
    /// </summary>
    public class CounselorApplication
    {

        public CounselorApplication() { }
        public CounselorApplication(string applicationMonth, string counselorId,
            string directorId, PhoneKind phoneKind, string mobile, string directorName="", string counselorName="", string org_Name="")
        {
            this.ApplicationMonth = applicationMonth;
            this.CounselorName = counselorName;
            this.CounselorId = counselorId;
            this.Org_Name = org_Name;
            this.DirectorName = directorName;
            this.DirectorId = directorId;
            this.PhoneKind = phoneKind;
            this.Mobile = mobile;
        }
        /// <summary>
        /// 申请ID 唯一性表示
        /// </summary>
        public Int64 Id { set; get; }
        /// <summary>
        /// 业务员工号
        /// </summary>
        public string CounselorId { set; get; }
        /// <summary>
        /// 业务员姓名
        /// </summary>
        public string CounselorName { set; get; }
        /// <summary>
        /// 业务员姓名
        /// </summary>
        public string Org_Name { set; get; }
        /// <summary>
        /// 业务员手机号码
        /// </summary>
        public string Mobile { set; get; }
        /// <summary>
        /// 区董事工号
        /// </summary>
        public string DirectorId { set; get; }
        /// <summary>
        /// 区董姓名
        /// </summary>
        public string DirectorName { set; get; }
        /// <summary>
        /// 申请电话类别 
        /// </summary>
        public PhoneKind PhoneKind { set; get; }
        /// <summary>
       /// 申请月份
       /// </summary>
        public string  ApplicationMonth { set; get; }
        /// <summary>
        ///   申请表中是否可加个申请时间 字段，之后同步申请表时可做 差异同步
        /// </summary>
        public string AddDate { set; get; }
        /// <summary>
        /// 处理状态
        /// </summary>
        public HandlerStatus Status { set; get; }

        /// <summary>
        /// 是否允许再次处理
        /// </summary>
        public bool IsEnabledHandelAgain
        {
            private set {
                value=false;
            }
            get
            {
                if (Status == HandlerStatus.待处理 || Status == HandlerStatus.无号码可用 || Status == HandlerStatus.系统错误)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }

        public override string ToString()
        {
            return "业务员: " + CounselorName + " 申请网站: " + PhoneKind +" 真实号码 "+Mobile+"  EShopApply表ID: " + Id;
        }

        //为其匹配的虚拟电话
        public VitualPhone VitualPhone { get; set; }
    }

    public enum HandlerStatus
    { 
        人员离职无需处理=-7,
        同一手机号被多个业务员使用=-6,
        同一业务员申请使用不同手机号=-5,
        系统错误=-4,
        号码已存在,
        同一网站只分配一个虚拟号码,
        无号码可用,
        待处理,
        分配成功
    }
    /// <summary>
    /// 虚拟电话类别
    /// </summary>
    public class PhoneKind
    {
        public PhoneKind(int id,string name)
        {
            this.Id = id;
            this.Name = name;
        }
        public int Id { private set; get; }
        public string Name { private set; get; }

        public override string ToString()
        {
            return Name;
        }
    }
}
